public class java2 {
    public static void main(String[] args) {
        String aa = "12345";
        System.out.println(customParseInt(aa));  // 输出：12345
    }
    public static int customParseInt(String str) {
        if (str == null || str.length() < 1 || str.length() > 10) {
            throw new IllegalArgumentException("字符串格式不符合要求");
        }

        int result = 0;
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (c < '0' || c > '9') {
                throw new IllegalArgumentException("字符串中包含非数字字符");
            }
            int digit = c - '0';

            result = result * 10 + digit;
        }

        return result;
    }
}
